package hd.util.load;

import android.os.Handler;
import android.os.Looper;


/**
 * 网页获取器
 * <p/>
 * Created by apple on 14-9-8.
 */
public class HttpLoader {

    public static void setOnHttpLoaderListener(final OnHttpLoaderListener listener) {
        listener.onStart();
        new Thread(new Runnable() {
            @Override
            public void run() {
                final String s = listener.onLoading();
                new Handler(Looper.getMainLooper()).post(new Runnable() {
                    @Override
                    public void run() {
                        listener.onFinish(s);
                    }
                });
            }
        }).start();
    }

    public interface OnHttpLoaderListener {

        public void onStart();

        public String onLoading();

        public void onFinish(String s);
    }
}
